package com.fgr.mapper;

import com.fgr.beans.Message;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.ui.Model;

import java.util.List;

public interface MessageMapper {

    public List<Message> selectAllMessage(Integer selectAllDonationBg);

    @Select("select * from an_message where msg_id=#{msgId}")
    public Message selectMessageByMsgId(Integer msgId);

    public Message selectMessageByMsgIdAuditing(Integer msgId);

    @Insert("insert into an_message(msg_uid,msg_time,msg_title,msg_phone,msg_text,msg_img,msg_publish) values(#{msgUserid},#{msgTime},#{msgTitle},#{msgPhone},#{msgText},#{msgImg},#{msgPublish})")
    public Integer addMessage(Message message);

    @Update("update an_message set msg_uid=#{msgUserid},msg_time=#{msgTime},msg_title=#{msgTitle},msg_phone=#{msgPhone},msg_text=#{msgText} where msg_id=#{msgId}")
    public Integer updateMessage(Message message);

    //审核通过
    @Update("update an_message set msg_publish=1 where msg_id=#{msgId}")
    public Integer updateMessagePublishByMsgId(Integer msgId);

    @Delete("delete from an_message where msg_id=#{msgId}")
    public Integer deleteMessageByMsgIdBg(Integer msgId);


}
